/*
** func.c for minitalk in /home/deluxe/Projets_Epi/minitalk
** 
** Made by Deluxe
** Login   <deluxe@epitech.net>
** 
** Started on  Tue Nov 13 17:15:38 2012 Deluxe
** Last update Tue Nov 13 17:27:18 2012 Deluxe
*/

#include "server.h"

void		my_putchar(char c)
{
  write(1, &c, 1);
}

void		my_putstr(char *str)
{
  int		i;

  i = 0;
  while (str[i])
    {
      my_putchar(str[i]);
      i++;
    }
}

int		my_getnbr(char *str)
{
  int		i;
  int		nb;
  int		neg;

  i = 0;
  nb = 0;
  neg = 0;
  while (str[i] == '+' || str[i] == '-')
    {
      neg = neg + 1;
      i = i + 1;
    }
  while (str[i] != '\0' && str[i] >= '0' && str[i] <= '9')
    {
      nb = nb * 10;
      nb = nb + str[i] - '0';
      i = i + 1;
    }
  if (neg % 2)
    neg = -neg;
  if (nb < 0)
    return (0);
  return (nb);
}
